package com.ai.chinamobileai.tool;

import com.ai.chinamobileai.domain.Package;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class MyTools {


    @Tool(description = "查找数据库中的套餐的内容")
    public List<Package> getConversationId(Package packages) {
        QueryWrapper<Package> wrapper = new QueryWrapper<Package>();
        wrapper.le("callDuration", packages.getCallDuration())
                .le("monthlyRent", packages.getMonthlyRent())
                .le("traffic", packages.getTraffic())
                .le("contractPeriod", packages.getContractPeriod());
        return packages.getSorts().stream().map(sort -> {
            if (sort.getAsc()) {
                wrapper.orderByAsc(sort.getField());
            } else {
                wrapper.orderByDesc(sort.getField());
            }
            return packages;
        }).toList();
    }
}
